package com.xiguaji.tiktok.v1.product.repository;

import com.xiguaji.tiktok.v1.product.model.ReportRecord;
import com.xiguaji.tiktok.v1.web.tiktok.dto.ReportResponse;
import org.springframework.data.jdbc.repository.query.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.List;
import java.util.Optional;

public interface ReportRecordRepository extends CrudRepository<ReportRecord,Long> {

    Optional<ReportRecord> findByUserIdAndUidAndPlatformTypeAndExpireTimeGreaterThan(long userId,long uid,int platformType,long timeSecond);

    @Query("select b.o_avatar300 avatar,b.o_uid uid,b.o_nickname nickname,b.o_unique_id unique_id,r.expire_time" +
            " from report_record r left  join blogger_main b on r.uid = b.o_uid where r.user_id = :userId and expire_time > :timeSecond" +
            " and r.platform_type = 1 ")
    List<ReportResponse> findByUserIdAndExpireTimeGreaterThan(long userId,long timeSecond);

    @Query("select b.o_avatar300 avatar,b.o_uid uid,b.o_nickname nickname,b.o_unique_id unique_id,r.expire_time" +
            " from report_record r left join blogger_main b on r.uid = b.o_uid where r.user_id = :userId and expire_time < :timeSecond" +
            " and r.platform_type = 1 ")
    List<ReportResponse> findByUserIdAndExpireTimeLessThan(long userId, long timeSecond);
}
